//
//  DSBut.m
//  budejie
//
//  Created by 秦榕 on 16/8/30.
//  Copyright © 2016年 Dason. All rights reserved.
//

#import "DSBut.h"
#import "UIView+Extension.h"
@implementation DSBut

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (void)setup
{
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setup];
    }
    return self;
}

- (void)awakeFromNib
{
    [self setup];
}
//+(instancetype)dsBUT
//{
//    DSBut*but = [[[NSBundle mainBundle] loadNibNamed:@"DSbut" owner:nil options:nil] lastObject];
//    return but;
//}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    // 调整图片
    self.imageView.X = 0;
    self.imageView.Y = 0;
    self.imageView.Width = self.Width;
    self.imageView.Height = self.imageView.Width;
    
    // 调整文字
    self.titleLabel.X = 0;
    self.titleLabel.Y = self.imageView.Height;
    self.titleLabel.Width = self.Width;
    self.titleLabel.Height = self.Height - self.titleLabel.Y;
    
}
@end
